home *** CD-ROM | disk | FTP | other *** search
Text File | 1992-06-03 | 50.4 KB | 2,213 lines |
- *** 1.2 1992/04/19 17:18:59
- --- PatchLev.h 1992/06/03 13:59:56
- ***************
- *** 1,5 ****
-
- ! #define PatchLevel "07"
-
- /*
- * the Patch Level above is to identify the version
- --- 1,5 ----
-
- ! #define PatchLevel "11"
-
- /*
- * the Patch Level above is to identify the version
- *** 1.1 1992/03/22 07:42:32
- --- dtoa.cc 1992/06/03 13:59:58
- ***************
- *** 30,35 ****
- --- 30,37 ----
- #define M_LN10 2.30258509299404568402
- #endif
-
- + // OBSOLETE ROUTINE!
- +
- char* dtoa(double fpnum, char cvt, int width, int prec)
- {
- // set up workspace
- *** 1.1 1992/03/22 07:42:32
- --- editbuf.cc 1992/06/03 13:59:59
- ***************
- *** 15,22 ****
- // License along with this library; if not, write to the Free
- // Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
- ! #include "ioprivat.h"
- ! #include "editbuf.h"
- #include <stddef.h>
- #ifdef __GNUG__
- #pragma implementation
- --- 15,22 ----
- // License along with this library; if not, write to the Free
- // Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
- ! #include <ioprivat.h>
- ! #include <editbuf.h>
- #include <stddef.h>
- #ifdef __GNUG__
- #pragma implementation
- *** 1.1 1992/03/22 07:42:32
- --- error.cc 1992/06/03 13:59:59
- ***************
- *** 19,24 ****
- --- 19,25 ----
- #pragma implementation
- #endif
- #include <builtin.h>
- + #include <osfcn.h>
-
- _VOLATILE_VOID default_one_arg_error_handler(const char* msg)
- {
- *** 1.1 1992/03/22 07:42:32
- --- fstream.cc 1992/06/03 14:00:00
- ***************
- *** 16,22 ****
- // Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
- #define _STREAM_COMPAT
- ! #include "ioprivat.h"
- #include <fstream.h>
- #ifdef __GNUG__
- #pragma implementation
- --- 16,22 ----
- // Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
- #define _STREAM_COMPAT
- ! #include <ioprivat.h>
- #include <fstream.h>
- #ifdef __GNUG__
- #pragma implementation
- *** 1.1 1992/03/22 07:42:32
- --- ident.c 1992/06/03 14:00:01
- ***************
- *** 1,2 ****
- ! #include "PatchLev.h"
- static char Ident[] = "$Patchlevel: " PatchLevel " $";
- --- 1,2 ----
- ! #include <PatchLev.h>
- static char Ident[] = "$Patchlevel: " PatchLevel " $";
- *** 1.1 1992/03/22 07:42:32
- --- igetline.cc 1992/06/03 14:00:01
- ***************
- *** 15,21 ****
- // License along with this library; if not, write to the Free
- // Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
- ! #include "iostream.h"
-
- istream& istream::getline(char* buf, int len, char delim)
- {
- --- 15,21 ----
- // License along with this library; if not, write to the Free
- // Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
- ! #include <iostream.h>
-
- istream& istream::getline(char* buf, int len, char delim)
- {
- *** 1.1 1992/03/22 07:42:32
- --- makebuf.cc 1992/06/03 14:00:02
- ***************
- *** 21,28 ****
- static char sccsid[] = "%W% (Berkeley) %G%";
- #endif /* LIBC_SCCS and not lint */
-
- ! #include "ioprivat.h"
- ! #include "fstream.h"
- #include <sys/types.h>
- #include <sys/stat.h>
-
- --- 21,28 ----
- static char sccsid[] = "%W% (Berkeley) %G%";
- #endif /* LIBC_SCCS and not lint */
-
- ! #include <ioprivat.h>
- ! #include <fstream.h>
- #include <sys/types.h>
- #include <sys/stat.h>
-
- ***************
- *** 32,37 ****
- --- 32,41 ----
- #define BUFSIZ __DEFAULT_BUFSIZ__
- #endif
-
- + #ifndef S_ISCHR
- + # define S_ISCHR(X) (((X) & S_IFMT) == S_IFCHR)
- + #endif
- +
- /*
- * Allocate a file buffer, or switch to unbuffered I/O.
- * Per the ANSI C standard, ALL tty devices default to line buffered.
- ***************
- *** 41,50 ****
- */
- int filebuf::doallocate()
- {
- - if (unbuffered()) {
- - setb(_fb._shortbuf, _fb._shortbuf+1, 0);
- - return 1;
- - }
- register size_t size, couldbetty;
- register char *p;
- struct stat st;
- --- 45,50 ----
- ***************
- *** 51,67 ****
-
- if (fd() < 0 || _fstat(fd(), &st) < 0) {
- couldbetty = 0;
- ! size = BUFSIZ;
- #if 0
- /* do not try to optimise fseek() */
- fp->_flags |= __SNPT;
- #endif
- } else {
- ! couldbetty = (st.st_mode & S_IFMT) == S_IFCHR;
- ! #if defined(atarist) || defined(NO_ST_BLKSIZE)
- ! size = BUFSIZ;
- #else
- ! size = st.st_blksize <= 0 ? BUFSIZ : st.st_blksize;
- #endif
- }
- #ifdef USE_MALLOC_BUF
- --- 51,67 ----
-
- if (fd() < 0 || _fstat(fd(), &st) < 0) {
- couldbetty = 0;
- ! size = _G_BUFSIZ;
- #if 0
- /* do not try to optimise fseek() */
- fp->_flags |= __SNPT;
- #endif
- } else {
- ! couldbetty = S_ISCHR(st.st_mode);
- ! #if (!defined(atarist)) && _G_HAVE_ST_BLKSIZE
- ! size = st.st_blksize <= 0 ? _G_BUFSIZ : st.st_blksize;
- #else
- ! size = _G_BUFSIZ;
- #endif
- }
- #ifdef USE_MALLOC_BUF
- *** 1.1 1992/03/22 21:19:02
- --- makefile.32 1992/06/03 14:00:03
- ***************
- *** 10,32 ****
- GXXLIB = $(LIB)
-
- # common subset of options; no int size or omit-frame-pointer:
- ! COMMONOPT = -O
- COMMONFLAGS =
- ! COMMONDEFINES = -DNO_LIBGXX_MALLOC
-
- COPTS= $(COMMONOPT) $(COMMONFLAGS) $(COMMONDEFINES) \
- ! -fstrength-reduce -DNDEBUG $(XFLAGS)
-
- GXXOPTS= $(COMMONOPT) $(COMMONFLAGS) $(COMMONDEFINES) \
- ! -felide-constructors -fsave-memoized $(XXFLAGS) -I$(GXXINC)
-
- # Base options CC; includes int size but not omit-frame-pointer
- CFFLAGS = $(COPTS)
- ! GXXFFLAGS = $(GXXOPTS)
-
- # normal CFLAGS including int size and omit-frame-pointer
- ! CFLAGS= $(CFFLAGS)
- ! GXXFLAGS = $(GXXFFLAGS)
-
- # cflags for stuff that needs to be compiled with 32 bit ints
- CLFLAGS= $(CFLAGS)
- --- 10,34 ----
- GXXLIB = $(LIB)
-
- # common subset of options; no int size or omit-frame-pointer:
- ! COMMONOPT = -O2 -fstrength-reduce
- COMMONFLAGS =
- ! COMMONDEFINES = -DNO_LIBGXX_MALLOC -DNDEBUG
-
- COPTS= $(COMMONOPT) $(COMMONFLAGS) $(COMMONDEFINES) \
- ! $(XFLAGS)
-
- + # dont know why but -fsave-memoized gives false errors
- + # about access to protected members
- GXXOPTS= $(COMMONOPT) $(COMMONFLAGS) $(COMMONDEFINES) \
- ! -felide-constructors $(XXFLAGS) -I$(GXXINC)
-
- # Base options CC; includes int size but not omit-frame-pointer
- CFFLAGS = $(COPTS)
- ! GXXFFLAGS = $(GXXOPTS)
-
- # normal CFLAGS including int size and omit-frame-pointer
- ! CFLAGS= $(CFFLAGS) -fomit-frame-pointer
- ! GXXFLAGS = $(GXXFFLAGS) -fomit-frame-pointer
-
- # cflags for stuff that needs to be compiled with 32 bit ints
- CLFLAGS= $(CFLAGS)
- ***************
- *** 36,42 ****
- ASFLAGS= -c
-
- # pre-processor flags
- ! PPFLAGS= -P -DNDEBUG
-
- # library targets
- LIBG++= g++.olb
- --- 38,44 ----
- ASFLAGS= -c
-
- # pre-processor flags
- ! PPFLAGS= -P # -DNDEBUG
-
- # library targets
- LIBG++= g++.olb
- *** 1.1 1992/03/22 21:19:02
- --- mincl 1992/06/03 14:00:03
- ***************
- *** 13,26 ****
- xgeom.cc xgetopt.cc xhypgeom.cc xinteger.cc xlognorm.cc xmlcg.cc \
- xnegexp.cc xnormal.cc xobstack.cc xpoisson.cc xrandom.cc xrationa.cc \
- xregex.cc xrndint.cc xrng.cc xsmplhis.cc xsmplsta.cc \
- ! xstring.cc xuniform.cc xweibull.cc xyzzy.cc xeh.cc
-
- IOSRC = editbuf.cc filebuf.cc fstream.cc igetline.cc indstrea.cc iostream.cc \
- makebuf.cc parsestr.cc sbufvfor.cc sbufvsca.cc sgetline.cc stdstrbu.cc \
- ! stdstrea.cc stream.cc streambu.cc strstrea.cc xplotfil.cc xsfile.cc
-
- ! OBJ = gnulib3.o _bin_del.o _bin_new.o _bin_nw.o ident.o\
- ! $(LIBSRC:.cc=.o) $(IOSRC:.cc=.o)
-
- all: $(ALL)
- all020: $(ALL020)
- --- 13,31 ----
- xgeom.cc xgetopt.cc xhypgeom.cc xinteger.cc xlognorm.cc xmlcg.cc \
- xnegexp.cc xnormal.cc xobstack.cc xpoisson.cc xrandom.cc xrationa.cc \
- xregex.cc xrndint.cc xrng.cc xsmplhis.cc xsmplsta.cc \
- ! xstring.cc xuniform.cc xweibull.cc xeh.cc
-
- IOSRC = editbuf.cc filebuf.cc fstream.cc igetline.cc indstrea.cc iostream.cc \
- makebuf.cc parsestr.cc sbufvfor.cc sbufvsca.cc sgetline.cc stdstrbu.cc \
- ! stdstrea.cc stream.cc streambu.cc strstrea.cc xplotfil.cc xsfile.cc \
- ! igetsb.cc
-
- ! #
- ! # NOTE:: dummy.o MUST be the last object on this list. otherwise you'll
- ! # end up with multiple definitions of global ctor/dtors
- ! #
- ! OBJ = gnulib3.o _bin_del.o _bin_new.o _bin_nw.o ident.o \
- ! $(LIBSRC:.cc=.o) $(IOSRC:.cc=.o) dummy.o
-
- all: $(ALL)
- all020: $(ALL020)
- *** 1.1 1992/03/22 07:42:32
- --- new.cc 1992/06/03 14:00:04
- ***************
- *** 1,5 ****
- - #ifndef NO_LIBGXX_MALLOC
- -
- // This may look like C code, but it is really -*- C++ -*-
-
- /*
- --- 1,3 ----
- ***************
- *** 22,34 ****
- #ifdef __GNUG__
- #pragma implementation
- #endif
- ! #include <stddef.h>
- ! #include <stdlib.h>
-
- void* operator new(size_t n)
- {
- return malloc (n);
- }
- -
- -
- #endif
- --- 20,31 ----
- #ifdef __GNUG__
- #pragma implementation
- #endif
- ! #include <new.h>
- !
- ! #if 0 /* ndef NO_LIBGXX_MALLOC */
-
- void* operator new(size_t n)
- {
- return malloc (n);
- }
- #endif
- *** 1.1 1992/03/22 07:42:32
- --- parsestr.cc 1992/06/03 14:00:04
- ***************
- *** 18,25 ****
- #ifdef __GNUG__
- #pragma implementation
- #endif
- ! #include "ioprivat.h"
- ! #include "parsestr.h"
-
- streambuf* parsebuf::setbuf(char*, size_t)
- {
- --- 18,25 ----
- #ifdef __GNUG__
- #pragma implementation
- #endif
- ! #include <ioprivat.h>
- ! #include <parsestr.h>
-
- streambuf* parsebuf::setbuf(char*, size_t)
- {
- *** 1.1 1992/03/22 07:42:32
- --- regex.cc 1992/06/03 14:00:05
- ***************
- *** 45,60 ****
- /* The `emacs' switch turns on certain special matching commands
- that make sense only in emacs. */
-
- ! #include "config.h"
- ! #include "lisp.h"
- ! #include "buffer.h"
- ! #include "syntax.h"
-
- #else /* not emacs */
-
- #include <string.h>
-
- ! #if defined (USG) || defined (STDC_HEADERS)
- #if !(defined(BSTRING) || defined(atarist))
- #define bcopy(s,d,n) memcpy((d),(s),(n))
- #define bcmp(s1,s2,n) memcmp((s1),(s2),(n))
- --- 45,61 ----
- /* The `emacs' switch turns on certain special matching commands
- that make sense only in emacs. */
-
- ! #include <config.h>
- ! #include <lisp.h>
- ! #include <buffer.h>
- ! #include <syntax.h>
-
- #else /* not emacs */
-
- #include <string.h>
- + #include <g_config.h>
-
- ! #if defined (_G_SYSV) || defined (STDC_HEADERS)
- #if !(defined(BSTRING) || defined(atarist))
- #define bcopy(s,d,n) memcpy((d),(s),(n))
- #define bcmp(s1,s2,n) memcmp((s1),(s2),(n))
- ***************
- *** 121,127 ****
- #endif
-
- /* Get the interface, including the syntax bits. */
- ! #include "regex.h"
-
-
- /* These are the command codes that appear in compiled regular
- --- 122,128 ----
- #endif
-
- /* Get the interface, including the syntax bits. */
- ! #include <regex.h>
-
-
- /* These are the command codes that appear in compiled regular
- ***************
- *** 220,232 ****
- #define NFAILURES 80
- #endif
-
- ! #ifdef CHAR_UNSIGNED
- ! #define SIGN_EXTEND_CHAR(c) ((c)>(char)127?(c)-256:(c)) /* for IBM RT */
- ! #endif
- #ifndef SIGN_EXTEND_CHAR
- ! #define SIGN_EXTEND_CHAR(x) (x)
- #endif
- !
-
- /* Store NUMBER in two contiguous bytes starting at DESTINATION. */
- #define STORE_NUMBER(destination, number) \
- --- 221,234 ----
- #define NFAILURES 80
- #endif
-
- !
- #ifndef SIGN_EXTEND_CHAR
- ! #ifdef __STDC__
- ! #define SIGN_EXTEND_CHAR(c) ((signed char)(c))
- ! #else
- ! #define SIGN_EXTEND_CHAR(c) (((c)^128) - 128) /* As in Harbison and Steele. */
- #endif
- ! #endif /* not SIGN_EXTEND_CHAR */
-
- /* Store NUMBER in two contiguous bytes starting at DESTINATION. */
- #define STORE_NUMBER(destination, number) \
- ***************
- *** 2637,2643 ****
-
- #ifdef canned
-
- ! #include "tests.h"
-
- typedef enum { extended_test, basic_test } test_type;
-
- --- 2639,2645 ----
-
- #ifdef canned
-
- ! #include <tests.h>
-
- typedef enum { extended_test, basic_test } test_type;
-
- *** 1.1 1992/03/22 07:42:32
- --- sbufvfor.cc 1992/06/03 14:00:05
- ***************
- *** 27,39 ****
- */
-
- #include <sys/types.h>
- ! #include "ioprivat.h"
- #include <string.h>
- - #if __STDC__
- #include <stdarg.h>
- - #else
- - #include <varargs.h>
- - #endif
-
- /*
- * Define FLOATING_POINT to get floating point.
- --- 27,35 ----
- */
-
- #include <sys/types.h>
- ! #include <ioprivat.h>
- #include <string.h>
- #include <stdarg.h>
-
- /*
- * Define FLOATING_POINT to get floating point.
- ***************
- *** 51,57 ****
- * worries about ungetc buffers and so forth.
- */
-
- ! class help_streambuf : public streambuf {
- public:
- char *buffer;
- size_t buf_size;
- --- 47,53 ----
- * worries about ungetc buffers and so forth.
- */
-
- ! class help_streambuf : public backupbuf {
- public:
- char *buffer;
- size_t buf_size;
- ***************
- *** 85,98 ****
-
- int help_vform(streambuf *sb, char const *fmt0, va_list ap)
- {
- ! char buf[BUFSIZ];
- ! help_streambuf helper(sb, buf, BUFSIZ);
- return helper.vform(fmt0, ap);
- }
-
- #ifdef FLOATING_POINT
-
- ! #include "floatio.h"
- #define BUF (MAXEXP+MAXFRACT+1) /* + decimal point */
- #define DEFPREC 6
- extern "C" double modf(double, double*);
- --- 81,97 ----
-
- int help_vform(streambuf *sb, char const *fmt0, va_list ap)
- {
- ! char buf[_G_BUFSIZ]; // WARNING: on the atari _G_BUFSIZ is a
- ! // variable. thats OK with GCC but other
- ! // compilers will barf!
- !
- ! help_streambuf helper(sb, buf, _G_BUFSIZ);
- return helper.vform(fmt0, ap);
- }
-
- #ifdef FLOATING_POINT
-
- ! #include <floatio.h>
- #define BUF (MAXEXP+MAXFRACT+1) /* + decimal point */
- #define DEFPREC 6
- extern "C" double modf(double, double*);
- ***************
- *** 122,130 ****
- #define ZEROPAD 0x20 /* zero (as opposed to blank) pad */
- #define HEXPREFIX 0x40 /* add 0x or 0X prefix */
-
- ! int streambuf::vform(char const *fmt0, _G_va_list args)
- {
- - va_list ap = (va_list)args;
- register char *fmt; /* format string */
- register int ch; /* character from fmt */
- register int n; /* handy integer (short term usage) */
- --- 121,128 ----
- #define ZEROPAD 0x20 /* zero (as opposed to blank) pad */
- #define HEXPREFIX 0x40 /* add 0x or 0X prefix */
-
- ! int streambuf::vform(char const *fmt0, _G_va_list ap)
- {
- register char *fmt; /* format string */
- register int ch; /* character from fmt */
- register int n; /* handy integer (short term usage) */
- ***************
- *** 190,199 ****
- (flags&LONGINT ? va_arg(ap, unsigned long) : \
- flags&SHORTINT ? (unsigned long)(unsigned short)va_arg(ap, int) : \
- (unsigned long)va_arg(ap, unsigned int))
- -
- - /* sorry, fprintf(read_only_file, "") returns EOF, not 0 */
- - if (!(_flags & _S_CAN_WRITE))
- - return (EOF);
-
- /* optimise cerr (and other unbuffered Unix files) */
- if (unbuffered())
- --- 188,193 ----
- *** 1.1 1992/03/22 07:42:32
- --- sbufvsca.cc 1992/06/03 14:00:06
- ***************
- *** 39,45 ****
- #endif
-
- #ifdef FLOATING_POINT
- ! #include "floatio.h"
- #define BUF (MAXEXP+MAXFRACT+3) /* 3 = sign + decimal point + NUL */
- #else
- #define BUF 40
- --- 39,45 ----
- #endif
-
- #ifdef FLOATING_POINT
- ! #include <floatio.h>
- #define BUF (MAXEXP+MAXFRACT+3) /* 3 = sign + decimal point + NUL */
- #else
- #define BUF 40
- ***************
- *** 84,92 ****
- extern "C" u_long strtoul(const char*, char**, int);
- static u_char *__sccl(register char *tab, register u_char *fmt);
-
- ! int streambuf::vscan(char const *fmt0, _G_va_list args)
- {
- - va_list ap = (va_list)args;
- register u_char *fmt = (u_char *)fmt0;
- register int c; /* character from format, or conversion */
- register size_t width; /* field width, or 0 */
- --- 84,91 ----
- extern "C" u_long strtoul(const char*, char**, int);
- static u_char *__sccl(register char *tab, register u_char *fmt);
-
- ! int streambuf::vscan(char const *fmt0, _G_va_list ap)
- {
- register u_char *fmt = (u_char *)fmt0;
- register int c; /* character from format, or conversion */
- register size_t width; /* field width, or 0 */
- ***************
- *** 358,368 ****
- *p++ = *_gptr++;
- if (--width == 0)
- break;
- ! if (sgetc() == EOF)
- ! if (p == p0) {
- goto input_failure;
- ! break;
- ! }
- }
- n = p - p0;
- if (n == 0)
- --- 357,367 ----
- *p++ = *_gptr++;
- if (--width == 0)
- break;
- ! if (sgetc() == EOF) {
- ! if (p == p0)
- goto input_failure;
- ! break;
- ! }
- }
- n = p - p0;
- if (n == 0)
- *** 1.1 1992/03/22 07:42:32
- --- sgetline.cc 1992/06/03 14:00:06
- ***************
- *** 15,21 ****
- // License along with this library; if not, write to the Free
- // Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
- ! #include "ioprivat.h"
-
- // Algorithm based on that used by Berkeley pre-4.4 fgets implementation.
-
- --- 15,21 ----
- // License along with this library; if not, write to the Free
- // Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
- ! #include <ioprivat.h>
-
- // Algorithm based on that used by Berkeley pre-4.4 fgets implementation.
-
- *** 1.1 1992/03/22 07:42:32
- --- stdstrea.cc 1992/06/03 14:00:06
- ***************
- *** 15,23 ****
- // License along with this library; if not, write to the Free
- // Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
- ! #include "ioprivat.h"
- ! #include "ioconfig.h"
- ! #ifdef NAMES_HAVE_UNDERSCORE
- #define UNDERSCORE "_"
- #else
- #define UNDERSCORE ""
- --- 15,24 ----
- // License along with this library; if not, write to the Free
- // Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
- ! #include <ioprivat.h>
- ! #include <g_config.h>
- !
- ! #if _G_NAMES_HAVE_UNDERSCORE
- #define UNDERSCORE "_"
- #else
- #define UNDERSCORE ""
- ***************
- *** 38,44 ****
- #define cout COUT
- #define cerr CERR
- #define clog CLOG
- ! #include "iostream.h"
- #undef cin
- #undef cout
- #undef cerr
- --- 39,45 ----
- #define cout COUT
- #define cerr CERR
- #define clog CLOG
- ! #include <iostream.h>
- #undef cin
- #undef cout
- #undef cerr
- *** 1.1 1992/03/22 07:42:32
- --- stream.cc 1992/06/03 14:00:07
- ***************
- *** 1,8 ****
- #include <stdarg.h>
- ! #include "ioprivat.h"
- ! #include "stream.h"
- ! #include "strstrea.h"
-
- static char Buffer[BUFSIZ];
- #define EndBuffer (Buffer+BUFSIZ)
- static char* next_chunk = Buffer; // Start of available part of Buffer.
- --- 1,16 ----
- #include <stdarg.h>
- ! #include <ioprivat.h>
- ! #include <stream.h>
- ! #include <strstrea.h>
- !
- ! // WARNING: dont do this for the atari because _G_BUFSIZ is a variable
- ! // not a constant.
- ! #ifndef atarist
- ! #undef BUFSIZ
- ! #define BUFSIZ _G_BUFSIZ
- ! #endif
-
- +
- static char Buffer[BUFSIZ];
- #define EndBuffer (Buffer+BUFSIZ)
- static char* next_chunk = Buffer; // Start of available part of Buffer.
- ***************
- *** 10,17 ****
- char* form(const char* format, ...)
- {
- size_t space_left = EndBuffer - next_chunk;
- ! if (space_left < (BUFSIZ>>2)) // If less that 25% of the space is available
- ! next_chunk = Buffer; // start over.
- char* buf = next_chunk;
-
- strstreambuf stream(buf, EndBuffer-buf-1, buf);
- --- 18,26 ----
- char* form(const char* format, ...)
- {
- size_t space_left = EndBuffer - next_chunk;
- ! // If less that 25% of the space is available start over.
- ! if (space_left < (BUFSIZ>>2))
- ! next_chunk = Buffer;
- char* buf = next_chunk;
-
- strstreambuf stream(buf, EndBuffer-buf-1, buf);
- ***************
- *** 44,51 ****
- if (needed < (2+neg) || ptr > EndBuffer)
- return NULL;
- *--ptr = 0;
- - if (neg)
- - *--ptr = '-';
-
- if (i == 0)
- *--ptr = '0';
- --- 53,58 ----
- ***************
- *** 58,63 ****
- --- 65,72 ----
- ch += '0';
- *--ptr = ch;
- }
- + if (neg)
- + *--ptr = '-';
- if (size == 0)
- return ptr;
- while (ptr > buf)
- *** 1.2 1992/04/19 17:18:59
- --- strstrea.cc 1992/06/03 14:00:07
- ***************
- *** 18,24 ****
- #ifdef __GNUG__
- #pragma implementation
- #endif
- ! #include "ioprivat.h"
- #include <strstrea.h>
-
- istrstream::istrstream(char *cp) : istream(NULL)
- --- 18,24 ----
- #ifdef __GNUG__
- #pragma implementation
- #endif
- ! #include <ioprivat.h>
- #include <strstrea.h>
-
- istrstream::istrstream(char *cp) : istream(NULL)
- ***************
- *** 135,141 ****
- setb(_buffer, _buffer+_size);
- setp(_buffer, _buffer+_size);
- setg(_buffer, _buffer, _buffer);
- - xsetflags(_S_CAN_READ | _S_CAN_WRITE);
- }
-
- strstreambuf::strstreambuf(int initial)
- --- 135,140 ----
- ***************
- *** 150,156 ****
- setb(_buffer, _buffer+_size);
- setp(_buffer, _buffer+_size);
- setg(_buffer, _buffer, _buffer);
- - xsetflags(_S_CAN_READ | _S_CAN_WRITE);
- }
-
- strstreambuf::strstreambuf(char *ptr, size_t size, char *pstart)
- --- 149,154 ----
- ***************
- *** 175,187 ****
- }
- else
- _size = size;
- - // I am not sure this change is correct... -- schenk@cpsc.ucalgary.ca
- - _len = _size;
- _buffer = ptr;
- - int new_flags = _S_CAN_READ;
- setb(_buffer, _buffer+_size);
- if (pstart) {
- - new_flags |= _S_CAN_WRITE;
- setp(_buffer, _buffer+_size);
- pbump(pstart-_buffer);
- setg(_buffer, _buffer, pstart);
- --- 173,181 ----
- ***************
- *** 190,196 ****
- setp(_buffer, _buffer);
- setg(_buffer, _buffer, _buffer+_size);
- }
- ! xsetflags(new_flags);
- }
-
- strstreambuf::~strstreambuf()
- --- 184,190 ----
- setp(_buffer, _buffer);
- setg(_buffer, _buffer, _buffer+_size);
- }
- ! _len = egptr() - _buffer;
- }
-
- strstreambuf::~strstreambuf()
- ***************
- *** 203,210 ****
- int mode /*=ios::in|ios::out*/)
- {
- size_t cur_size = pcount();
- ! streampos new_pos = EOF;
- ! if ((mode & ios::in) && (xflags() & _S_CAN_READ)) {
- switch (dir) {
- case ios::end:
- off += cur_size;
- --- 197,206 ----
- int mode /*=ios::in|ios::out*/)
- {
- size_t cur_size = pcount();
- ! streampos new_pos = EOF;
- !
- ! // Move the get pointer, if requested.
- ! if (mode & ios::in) {
- switch (dir) {
- case ios::end:
- off += cur_size;
- ***************
- *** 216,226 ****
- break;
- }
- if (off < 0 || (size_t)off > cur_size)
- ! return (streampos)(EOF);
- setg(_buffer, _buffer + off, _buffer + cur_size);
- new_pos = off;
- }
- ! if ((mode & ios::out) && (xflags() & _S_CAN_WRITE)) {
- switch (dir) {
- case ios::end:
- off += cur_size;
- --- 212,224 ----
- break;
- }
- if (off < 0 || (size_t)off > cur_size)
- ! return EOF;
- setg(_buffer, _buffer + off, _buffer + cur_size);
- new_pos = off;
- }
- !
- ! // Move the put pointer, if requested.
- ! if (mode & ios::out) {
- switch (dir) {
- case ios::end:
- off += cur_size;
- ***************
- *** 232,238 ****
- break;
- }
- if (off < 0 || (size_t)off > cur_size)
- ! return (streampos)(EOF);
- pbump(_buffer + off - pptr());
- new_pos = off;
- }
- --- 230,236 ----
- break;
- }
- if (off < 0 || (size_t)off > cur_size)
- ! return EOF;
- pbump(_buffer + off - pptr());
- new_pos = off;
- }
- *** 1.1 1992/03/22 07:42:32
- --- timer.cc 1992/06/03 14:00:07
- ***************
- *** 31,49 ****
- #if 1
-
- #include <sys/types.h>
- ! #if defined(USG) || defined(atarist)
- extern "C" {
- #include <sys/param.h>
- #include <sys/times.h>
- }
- ! #else
- ! #include <osfcn.h>
- #endif
- -
- - #if defined(USG) || defined(atarist)
- static struct tms Old_Time;
- static struct tms New_Time;
- #else
- static struct rusage Old_Time;
- static struct rusage New_Time;
- #endif
- --- 31,49 ----
- #if 1
-
- #include <sys/types.h>
- ! #include <g_config.h>
- ! #if !_G_HAVE_SYS_RESOURCE
- extern "C" {
- #include <sys/param.h>
- #include <sys/times.h>
- }
- ! #if !defined (HZ) && defined(CLK_TCK)
- ! #define HZ CLK_TCK
- #endif
- static struct tms Old_Time;
- static struct tms New_Time;
- #else
- + #include <osfcn.h>
- static struct rusage Old_Time;
- static struct rusage New_Time;
- #endif
- ***************
- *** 52,58 ****
- double start_timer()
- {
- Timer_Set = 1;
- ! #if defined(USG) || defined(atarist)
- times(&Old_Time);
- return((double) Old_Time.tms_utime / HZ);
- #else
- --- 52,58 ----
- double start_timer()
- {
- Timer_Set = 1;
- ! #if !_G_HAVE_SYS_RESOURCE
- times(&Old_Time);
- return((double) Old_Time.tms_utime / HZ);
- #else
- ***************
- *** 72,84 ****
- }
- else {
- /* get process time */
- ! #if defined(USG) || defined(atarist)
- times(&New_Time);
- #else
- getrusage(RUSAGE_SELF,&New_Time);
- #endif
- if (Last_Time == 0.0) {
- ! #if defined(USG) || defined(atarist)
- return((double) (New_Time.tms_utime - Old_Time.tms_utime) / HZ);
- #else
- return((New_Time.ru_utime.tv_sec - Old_Time.ru_utime.tv_sec) +
- --- 72,84 ----
- }
- else {
- /* get process time */
- ! #if !_G_HAVE_SYS_RESOURCE
- times(&New_Time);
- #else
- getrusage(RUSAGE_SELF,&New_Time);
- #endif
- if (Last_Time == 0.0) {
- ! #if !_G_HAVE_SYS_RESOURCE
- return((double) (New_Time.tms_utime - Old_Time.tms_utime) / HZ);
- #else
- return((New_Time.ru_utime.tv_sec - Old_Time.ru_utime.tv_sec) +
- ***************
- *** 87,93 ****
- #endif
- }
- else {
- ! #if defined(USG) || defined(atarist)
- return((double) New_Time.tms_utime / HZ - Last_Time);
- #else
- return((New_Time.ru_utime.tv_sec +
- --- 87,93 ----
- #endif
- }
- else {
- ! #if !_G_HAVE_SYS_RESOURCE
- return((double) New_Time.tms_utime / HZ - Last_Time);
- #else
- return((New_Time.ru_utime.tv_sec +
- *** 1.2 1992/03/22 21:19:02
- --- xbitset.cc 1992/06/03 14:00:08
- ***************
- *** 30,35 ****
- --- 30,36 ----
- #include <new.h>
- #include <builtin.h>
- #include <string.h>
- + #include <strstrea.h>
-
- void BitSet::error(const char* msg) const
- {
- ***************
- *** 752,807 ****
- const char* BitSettoa(const BitSet& x, char f, char t, char star)
- {
- trim(x.rep);
- -
- size_t wrksiz = (x.rep->len + 1) * BITSETBITS + 2;
- char* fmtbase = (char *) _libgxx_fmtq.alloc(wrksiz);
- ! char* fmt = fmtbase;
- !
- ! const unsigned short* s = x.rep->s;
- ! const unsigned short* top = &(s[x.rep->len - 1]);
- !
- ! while (s < top)
- ! {
- ! unsigned short a = *s++;
- ! for (int j = 0; j < BITSETBITS; ++j)
- ! {
- ! *fmt++ = (a & 1)? t : f;
- ! a >>= 1;
- ! }
- ! }
- !
- ! if (!x.rep->virt)
- ! {
- ! unsigned short a = *s;
- ! if (x.rep->len != 0)
- ! {
- ! for (int j = 0; j < BITSETBITS && a != 0; ++j)
- ! {
- ! *fmt++ = (a & 1)? t : f;
- ! a >>= 1;
- ! }
- ! }
- ! *fmt++ = f;
- ! }
- ! else
- ! {
- ! unsigned short a = *s;
- ! unsigned short mask = ONES;
- ! unsigned short himask = (1 << (BITSETBITS - 1)) - 1;
- ! if (x.rep->len != 0)
- ! {
- ! for (int j = 0; j < BITSETBITS && a != mask; ++j)
- ! {
- ! *fmt++ = (a & 1)? t : f;
- ! a = (a >> 1) & himask;
- ! mask = (mask >> 1) & himask;
- ! }
- ! }
- ! *fmt++ = t;
- ! }
- !
- ! *fmt++ = star;
- ! *fmt++ = 0;
- return fmtbase;
- }
-
- --- 753,764 ----
- const char* BitSettoa(const BitSet& x, char f, char t, char star)
- {
- trim(x.rep);
- size_t wrksiz = (x.rep->len + 1) * BITSETBITS + 2;
- char* fmtbase = (char *) _libgxx_fmtq.alloc(wrksiz);
- ! ostrstream stream(fmtbase, wrksiz);
- !
- ! x.printon(stream, f, t, star);
- ! stream << ends;
- return fmtbase;
- }
-
- ***************
- *** 950,956 ****
-
- ostream& operator << (ostream& s, const BitSet& x)
- {
- ! return s << BitSettoa(x);
- }
-
- int BitSet::OK() const
- --- 907,966 ----
-
- ostream& operator << (ostream& s, const BitSet& x)
- {
- ! if (s.opfx())
- ! x.printon(s);
- ! return s;
- ! }
- !
- ! void BitSet::printon(ostream& s, char f, char t, char star) const
- ! // FIXME: Does not respect s.width()!
- ! {
- ! trim(rep);
- ! register streambuf* sb = s.rdbuf();
- ! const unsigned short* s = rep->s;
- ! const unsigned short* top = &(s[rep->len - 1]);
- !
- ! while (s < top)
- ! {
- ! unsigned short a = *s++;
- ! for (int j = 0; j < BITSETBITS; ++j)
- ! {
- ! sb->sputc((a & 1)? t : f);
- ! a >>= 1;
- ! }
- ! }
- !
- ! if (!rep->virt)
- ! {
- ! unsigned short a = *s;
- ! if (rep->len != 0)
- ! {
- ! for (int j = 0; j < BITSETBITS && a != 0; ++j)
- ! {
- ! sb->sputc((a & 1)? t : f);
- ! a >>= 1;
- ! }
- ! }
- ! sb->sputc(f);
- ! }
- ! else
- ! {
- ! unsigned short a = *s;
- ! unsigned short mask = ONES;
- ! unsigned short himask = (1 << (BITSETBITS - 1)) - 1;
- ! if (rep->len != 0)
- ! {
- ! for (int j = 0; j < BITSETBITS && a != mask; ++j)
- ! {
- ! sb->sputc((a & 1)? t : f);
- ! a = (a >> 1) & himask;
- ! mask = (mask >> 1) & himask;
- ! }
- ! }
- ! sb->sputc(t);
- ! }
- !
- ! sb->sputc(star);
- }
-
- int BitSet::OK() const
- *** 1.1 1992/03/22 07:42:32
- --- xbitstri.cc 1992/06/03 14:00:09
- ***************
- *** 29,34 ****
- --- 29,35 ----
- #include <xallocri.h>
- #include <new.h>
- #include <builtin.h>
- + #include <strstrea.h>
-
- void BitString::error(const char* msg) const
- {
- ***************
- *** 1970,2001 ****
-
- extern AllocRing _libgxx_fmtq;
-
- ! const char* BitStringtoa(const BitString& x, char f, char t)
- {
- ! int wrksiz = x.length() + 2;
- ! char* fmtbase = (char *) _libgxx_fmtq.alloc(wrksiz);
- ! char* fmt = fmtbase;
- ! size_t xl = x.rep->len;
- ! const unsigned short* s = x.rep->s;
- unsigned short a = 0;
-
- ! for (size_t i = 0; i < xl; ++i)
- {
- if (i % BITSTRBITS == 0)
- ! a = *s++;
- ! *fmt++ = (a & 1)? t : f;
- a >>= 1;
- }
- !
- ! *fmt = 0;
-
- return fmtbase;
- }
-
- -
- ostream& operator << (ostream& s, const BitString& x)
- {
- ! return s << BitStringtoa(x);
- }
-
- const char* BitPatterntoa(const BitPattern& p, char f,char t,char x)
- --- 1971,2010 ----
-
- extern AllocRing _libgxx_fmtq;
-
- ! void BitString::printon(ostream& os, char f, char t) const
- {
- ! size_t wrksiz = length() + 2;
- ! size_t xl = rep->len;
- ! const unsigned short* ptr = rep->s;
- ! register streambuf *sb = os.rdbuf();
- unsigned short a = 0;
-
- ! for (size_t i = 0; i < xl; ++i)
- {
- if (i % BITSTRBITS == 0)
- ! a = *ptr++;
- ! sb->sputc((a & 1)? t : f);
- a >>= 1;
- }
- ! }
-
- + const char* BitStringtoa(const BitString& x, char f, char t)
- + {
- + size_t wrksiz = x.length() + 2;
- + char* fmtbase = (char *) _libgxx_fmtq.alloc(wrksiz);
- + char* fmt = fmtbase;
- + ostrstream stream(fmtbase, wrksiz);
- +
- + x.printon(stream, f, t);
- + stream << ends;
- return fmtbase;
- }
-
- ostream& operator << (ostream& s, const BitString& x)
- {
- ! if (s.opfx())
- ! x.printon(s);
- ! return s;
- }
-
- const char* BitPatterntoa(const BitPattern& p, char f,char t,char x)
- ***************
- *** 2006,2015 ****
-
- size_t wrksiz = l + 2;
- char* fmtbase = (char *) _libgxx_fmtq.alloc(wrksiz);
- ! char* fmt = fmtbase;
-
- ! const unsigned short* ps = p.pattern.rep->s;
- ! const unsigned short* ms = p.mask.rep->s;
- unsigned short a = 0;
- unsigned short m = 0;
-
- --- 2015,2036 ----
-
- size_t wrksiz = l + 2;
- char* fmtbase = (char *) _libgxx_fmtq.alloc(wrksiz);
- ! ostrstream stream(fmtbase, wrksiz);
- !
- ! p.printon(stream, f, t, x);
- ! stream << ends;
- ! return fmtbase;
- ! }
- !
- ! void BitPattern::printon(ostream& s, char f,char t,char x) const
- ! {
- ! unsigned int pl = pattern.rep->len;
- ! unsigned int ml = mask.rep->len;
- ! unsigned int l = (pl <= ml)? pl : ml;
- ! register streambuf *sb = s.rdbuf();
-
- ! const unsigned short* ps = pattern.rep->s;
- ! const unsigned short* ms = mask.rep->s;
- unsigned short a = 0;
- unsigned short m = 0;
-
- ***************
- *** 2021,2041 ****
- m = *ms++;
- }
- if (m & 1)
- ! *fmt++ =(a & 1)? t : f;
- else
- ! *fmt++ = x;
- a >>= 1;
- m >>= 1;
- }
- -
- - *fmt = 0;
- - return fmtbase;
- }
-
- -
- ostream& operator << (ostream& s, const BitPattern& x)
- {
- ! return s << BitPatterntoa(x);
- }
-
-
- --- 2042,2060 ----
- m = *ms++;
- }
- if (m & 1)
- ! sb->sputc((a & 1)? t : f);
- else
- ! sb->sputc(x);
- a >>= 1;
- m >>= 1;
- }
- }
-
- ostream& operator << (ostream& s, const BitPattern& x)
- {
- ! if (s.opfx())
- ! x.printon(s);
- ! return s;
- }
-
-
- *** 1.1 1992/03/22 07:42:32
- --- xcursesw.cc 1992/06/03 14:00:09
- ***************
- *** 21,31 ****
- #include <stdarg.h>
- #include <builtin.h>
- #include <values.h>
- - #include <xcursesw.h>
- #ifndef _OLD_STREAMS
- #include <strstream.h>
- #include <ioprivate.h>
- #endif
-
- int CursesWindow::count = 0;
-
- --- 21,33 ----
- #include <stdarg.h>
- #include <builtin.h>
- #include <values.h>
- #ifndef _OLD_STREAMS
- #include <strstream.h>
- #include <ioprivate.h>
- #endif
- + // Include CurseW.h and/or curses.h *after* iostream includes,
- + // because curses.h defines a clear macro that conflicts with iostream. Sigh.
- + #include <xcursesw.h>
-
- int CursesWindow::count = 0;
-
- ***************
- *** 47,53 ****
- va_start(args, fmt);
- #ifdef VMS
- int result = wscanw(w , fmt , args);
- ! #else
- char buf[BUFSIZ];
- int result = wgetstr(w, buf);
- if (result == OK) {
- --- 49,55 ----
- va_start(args, fmt);
- #ifdef VMS
- int result = wscanw(w , fmt , args);
- ! #else /* NOT VMS */
- char buf[BUFSIZ];
- int result = wgetstr(w, buf);
- if (result == OK) {
- ***************
- *** 62,73 ****
- b._ptr = buf;
- b._cnt = BUFSIZ;
- result = _doscan(&b, fmt, args);
- ! #else
- result = vsscanf(buf, fmt, args);
- ! #endif
- #endif /* _OLD_STREAMS */
- - #endif
- }
- va_end(args);
- return result;
- }
- --- 64,75 ----
- b._ptr = buf;
- b._cnt = BUFSIZ;
- result = _doscan(&b, fmt, args);
- ! #else /* HAVE_VSCANF */
- result = vsscanf(buf, fmt, args);
- ! #endif /* HAVE_VSCANF */
- #endif /* _OLD_STREAMS */
- }
- + #endif /* !VMS */
- va_end(args);
- return result;
- }
- ***************
- *** 76,82 ****
- {
- va_list args;
- va_start(args, fmt);
- - #ifndef VMS
- char buf[BUFSIZ];
- int result = wmove(w, y, x);
- if (result == OK)
- --- 78,83 ----
- ***************
- *** 83,89 ****
- #ifdef VMS
- result=wscanw(w , fmt , args);
- #else /* !VMS */
- ! {
- result = wgetstr(w, buf);
- if (result == OK) {
- #ifndef _OLD_STREAMS
- --- 84,90 ----
- #ifdef VMS
- result=wscanw(w , fmt , args);
- #else /* !VMS */
- ! {
- result = wgetstr(w, buf);
- if (result == OK) {
- #ifndef _OLD_STREAMS
- ***************
- *** 101,110 ****
- result = vsscanf(buf, fmt, args);
- #endif
- #endif /* OLD_STREAMS */
- - #endif /* !VMS */
- - }
- }
- ! #endif
- va_end(args);
- return result;
- }
- --- 102,110 ----
- result = vsscanf(buf, fmt, args);
- #endif
- #endif /* OLD_STREAMS */
- }
- ! }
- ! #endif /* !VMS */
- va_end(args);
- return result;
- }
- *** 1.1 1992/03/22 07:42:32
- --- xeh.cc 1992/06/03 14:00:10
- ***************
- *** 7,12 ****
- --- 7,13 ----
- #endif
- #include <setjmp.h>
- #include <stream.h>
- + #include <osfcn.h>
-
- struct
- ExceptionHandler
- *** 1.1 1992/03/22 07:42:32
- --- xfix.cc 1992/06/03 14:00:10
- ***************
- *** 26,31 ****
- --- 26,32 ----
- #include <std.h>
- #include <xobstack.h>
- #include <xallocri.h>
- + #include <strstrea.h>
-
- // default parameters
-
- ***************
- *** 451,468 ****
-
- extern AllocRing _libgxx_fmtq;
-
- char* Ftoa(Fix& x, int width)
- {
- int wrksiz = width + 2;
- ! char *s = (char *) _libgxx_fmtq.alloc(wrksiz);
- ! char format[100];
- ! double val = value(x);
- ! if (val < 0)
- ! sprintf(format,"%%%d.%dlf",width-2,width-3);
- ! else
- ! sprintf(format," %%%d.%dlf",width-2,width-3);
- ! sprintf(s,format,val);
- ! return s;
- }
-
- extern Obstack _libgxx_io_ob;
- --- 452,480 ----
-
- extern AllocRing _libgxx_fmtq;
-
- + void Fix::printon(ostream& s, int width)
- + {
- + char format[20];
- + double val = value(*this);
- + int old_precision = s.precision(width-3);
- + fmtflags old_flags = s.setf(ios::fixed, ios::fixed|ios::scientific);
- + if (val >= 0)
- + s << ' ';
- + s.width(width-2);
- + s << val;
- + s.precision(old_precision);
- + s.flags(old_flags);
- + }
- +
- char* Ftoa(Fix& x, int width)
- {
- int wrksiz = width + 2;
- ! char *fmtbase = (char *) _libgxx_fmtq.alloc(wrksiz);
- ! ostrstream stream(fmtbase, wrksiz);
- !
- ! x.printon(stream, width);
- ! stream << ends;
- ! return fmtbase;
- }
-
- extern Obstack _libgxx_io_ob;
- ***************
- *** 542,548 ****
- cout << "len = " << x.rep->len << "\n";
- cout << "siz = " << x.rep->siz << "\n";
- cout << "ref = " << x.rep->ref << "\n";
- ! cout << "man = " << Itoa(mantissa(x),16,4*x.rep->siz) << "\n";
- cout << "val = " << value(x) << "\n";
- }
-
- --- 554,569 ----
- cout << "len = " << x.rep->len << "\n";
- cout << "siz = " << x.rep->siz << "\n";
- cout << "ref = " << x.rep->ref << "\n";
- ! cout << "man = ";
- ! #ifdef _OLD_STREAMS
- ! cout << Itoa(mantissa(x),16,4*x.rep->siz);
- ! #else
- ! int old_flags = cout.setf(ios::hex, ios::hex|ios::dec|ios::oct);
- ! cout.width(4*x.rep->siz);
- ! cout << mantissa(x);
- ! cout.setf(old_flags, ios::hex|ios::dec|ios::oct);
- ! #endif
- ! cout << "\n";
- cout << "val = " << value(x) << "\n";
- }
-
- *** 1.2 1992/03/22 21:19:02
- --- xfix24.cc 1992/06/03 14:00:11
- ***************
- *** 204,234 ****
- return r;
- }
-
- - Fix48 operator * (Fix48& a, int b)
- - {
- - twolongs r;
- - int bpos = (b >= 0);
- - unsigned ub = (bpos)? b : -b;
- - if ( ub >= 65536L ) {
- - r = (bpos)? Fix48_m_max : Fix48_m_min;
- - a.range_error(r);
- - }
- - else {
- - unsigned long
- - lo_r = (a.m.l & 0xffff) * ub,
- - mi_r = ((a.m.l >> 16) & 0xffff) * ub,
- - hi_r = a.m.u * ub;
- - r.l = lo_r + (mi_r << 16);
- - r.u = hi_r + ((mi_r >> 8) & 0x00ffff00L);
- - if ( !bpos ) {
- - unsigned long l = r.l;
- - r.l = -r.l;
- - r.u = ~r.u + ((l ^ r.l) & Fix24_msb ? 0 : Fix24_lsb);
- - }
- - }
- - return r;
- - }
- -
- Fix48 operator << (Fix48& a, int b)
- {
- twolongs r; r.u = r.l = 0;
- --- 204,209 ----
- *** 1.1 1992/03/22 07:42:32
- --- xinteger.cc 1992/06/03 14:00:12
- ***************
- *** 66,72 ****
- --- 66,76 ----
- #define MALLOC_MIN_OVERHEAD 4
- #endif
-
- + IntRep _ZeroRep = {1, 0, 1, {0}};
- + IntRep _OneRep = {1, 0, 1, {1}};
- + IntRep _MinusOneRep = {1, 0, 0, {1}};
-
- +
- // utilities to extract and transfer bits
-
- // get low bits
- ***************
- *** 177,183 ****
- scpy(src, rep->s, srclen);
- Iclear_from(rep, srclen);
-
- ! if (old != rep && old != 0) delete old;
- return rep;
- }
-
- --- 181,187 ----
- scpy(src, rep->s, srclen);
- Iclear_from(rep, srclen);
-
- ! if (old != rep && old != 0 && !STATIC_IntRep(old)) delete old;
- return rep;
- }
-
- ***************
- *** 188,194 ****
- IntRep* rep;
- if (old == 0 || newlen > old->sz)
- {
- ! if (old != 0) delete old;
- rep = Inew(newlen);
- }
- else
- --- 192,198 ----
- IntRep* rep;
- if (old == 0 || newlen > old->sz)
- {
- ! if (old != 0 && !STATIC_IntRep(old)) delete old;
- rep = Inew(newlen);
- }
- else
- ***************
- *** 221,227 ****
- rep = Inew(newlen);
- scpy(old->s, rep->s, oldlen);
- rep->sgn = old->sgn;
- ! delete old;
- }
- else
- rep = old;
- --- 225,231 ----
- rep = Inew(newlen);
- scpy(old->s, rep->s, oldlen);
- rep->sgn = old->sgn;
- ! if (!STATIC_IntRep(old)) delete old;
- }
- else
- rep = old;
- ***************
- *** 257,263 ****
- int newlen = src->len;
- if (old == 0 || newlen > old->sz)
- {
- ! if (old != 0) delete old;
- rep = Inew(newlen);
- }
- else
- --- 261,267 ----
- int newlen = src->len;
- if (old == 0 || newlen > old->sz)
- {
- ! if (old != 0 && !STATIC_IntRep(old)) delete old;
- rep = Inew(newlen);
- }
- else
- ***************
- *** 294,300 ****
- IntRep* rep;
- if (old == 0 || srclen > old->sz)
- {
- ! if (old != 0) delete old;
- rep = Inew(srclen);
- }
- else
- --- 298,304 ----
- IntRep* rep;
- if (old == 0 || srclen > old->sz)
- {
- ! if (old != 0 && !STATIC_IntRep(old)) delete old;
- rep = Inew(srclen);
- }
- else
- ***************
- *** 313,328 ****
-
- IntRep* Icopy_zero(IntRep* old)
- {
- - IntRep* rep;
- if (old == 0)
- ! rep = Inew(0);
- ! else
- ! rep = old;
-
- ! rep->len = 0;
- ! rep->sgn = I_POSITIVE;
-
- ! return rep;
- }
-
- // special case for 1 or -1
- --- 317,329 ----
-
- IntRep* Icopy_zero(IntRep* old)
- {
- if (old == 0)
- ! return &_ZeroRep;
-
- ! old->len = 0;
- ! old->sgn = I_POSITIVE;
-
- ! return old;
- }
-
- // special case for 1 or -1
- ***************
- *** 329,348 ****
-
- IntRep* Icopy_one(IntRep* old, int newsgn)
- {
- - IntRep* rep;
- if (old == 0 || 1 > old->sz)
- {
- ! if (old != 0) delete old;
- ! rep = Inew(1);
- }
- - else
- - rep = old;
-
- ! rep->sgn = newsgn;
- ! rep->len = 1;
- ! rep->s[0] = 1;
-
- ! return rep;
- }
-
- // convert to a legal two's complement long if possible
- --- 330,346 ----
-
- IntRep* Icopy_one(IntRep* old, int newsgn)
- {
- if (old == 0 || 1 > old->sz)
- {
- ! if (old != 0 && !STATIC_IntRep(old)) delete old;
- ! return newsgn==I_NEGATIVE ? &_MinusOneRep : &_OneRep;
- }
-
- ! old->sgn = newsgn;
- ! old->len = 1;
- ! old->s[0] = 1;
-
- ! return old;
- }
-
- // convert to a legal two's complement long if possible
- ***************
- *** 1234,1241 ****
- q = Icalloc(q, ql);
- do_divide(r->s, yy->s, yl, q->s, ql);
-
- ! if (yy != y) delete yy;
- ! delete r;
- }
- q->sgn = samesign;
- Icheck(q);
- --- 1232,1239 ----
- q = Icalloc(q, ql);
- do_divide(r->s, yy->s, yl, q->s, ql);
-
- ! if (yy != y && !STATIC_IntRep(yy)) delete yy;
- ! if (!STATIC_IntRep(r)) delete r;
- }
- q->sgn = samesign;
- Icheck(q);
- ***************
- *** 1302,1308 ****
- q = Icalloc(q, ql);
- do_divide(r->s, ys, yl, q->s, ql);
-
- ! delete r;
- }
- q->sgn = samesign;
- Icheck(q);
- --- 1300,1306 ----
- q = Icalloc(q, ql);
- do_divide(r->s, ys, yl, q->s, ql);
-
- ! if (!STATIC_IntRep(r)) delete r;
- }
- q->sgn = samesign;
- Icheck(q);
- ***************
- *** 1384,1390 ****
- }
- Icheck(r);
- rem = Itolong(r);
- ! delete r;
- }
- rem = abs(rem);
- if (xsgn == I_NEGATIVE) rem = -rem;
- --- 1382,1388 ----
- }
- Icheck(r);
- rem = Itolong(r);
- ! if (!STATIC_IntRep(r)) delete r;
- }
- rem = abs(rem);
- if (xsgn == I_NEGATIVE) rem = -rem;
- ***************
- *** 1453,1459 ****
- q = Icalloc(q, ql);
- do_divide(r->s, yy->s, yl, q->s, ql);
-
- ! if (yy != y) delete yy;
- if (prescale != 1)
- {
- Icheck(r);
- --- 1451,1457 ----
- q = Icalloc(q, ql);
- do_divide(r->s, yy->s, yl, q->s, ql);
-
- ! if (yy != y && !STATIC_IntRep(yy)) delete yy;
- if (prescale != 1)
- {
- Icheck(r);
- ***************
- *** 1507,1513 ****
-
- do_divide(r->s, yy->s, yl, 0, xl - yl + 1);
-
- ! if (yy != y) delete yy;
-
- if (prescale != 1)
- {
- --- 1505,1511 ----
-
- do_divide(r->s, yy->s, yl, 0, xl - yl + 1);
-
- ! if (yy != y && !STATIC_IntRep(yy)) delete yy;
-
- if (prescale != 1)
- {
- ***************
- *** 1947,1954 ****
- t = add(t, 0, u, 0, t);
- }
- }
- ! delete t;
- ! delete v;
- if (k != 0) u = lshift(u, k, u);
- return u;
- }
- --- 1945,1952 ----
- t = add(t, 0, u, 0, t);
- }
- }
- ! if (!STATIC_IntRep(t)) delete t;
- ! if (!STATIC_IntRep(v)) delete v;
- if (k != 0) u = lshift(u, k, u);
- return u;
- }
- ***************
- *** 2006,2012 ****
- else
- b = multiply(b, b, b);
- }
- ! delete b;
- }
- r->sgn = sgn;
- Icheck(r);
- --- 2004,2010 ----
- else
- b = multiply(b, b, b);
- }
- ! if (!STATIC_IntRep(b)) delete b;
- }
- r->sgn = sgn;
- Icheck(r);
- ***************
- *** 2160,2183 ****
- #ifdef _OLD_STREAMS
- return s << Itoa(y.rep);
- #else
- ! int base = (s.flags() & ios::oct) ? 8 : (s.flags() & ios::hex) ? 16 : 10;
- int align_right = !(s.flags() & ios::left);
- int showpos = s.flags() & ios::showpos;
- int showbase = s.flags() & ios::showbase;
- char fillchar = s.fill();
- char Xcase = (s.flags() & ios::uppercase)? 'X' : 'x';
- ! int width = s.width();
- ! const IntRep* x = y.rep;
- int fmtlen = (x->len + 1) * I_SHIFT / lg(base) + 4 + width;
- char* fmtbase = new char[fmtlen];
- char* f = cvtItoa(x, fmtbase, fmtlen, base, showbase, width, align_right,
- ! fillchar, Xcase, showpos);
- s.write(f, fmtlen);
- delete fmtbase;
- - return s;
- - #endif
- }
- -
-
- char* cvtItoa(const IntRep* x, char* fmt, int& fmtlen, int base, int showbase,
- int width, int align_right, char fillchar, char Xcase,
- --- 2158,2188 ----
- #ifdef _OLD_STREAMS
- return s << Itoa(y.rep);
- #else
- ! if (s.opfx())
- ! {
- ! int base = (s.flags() & ios::oct) ? 8 : (s.flags() & ios::hex) ? 16 : 10;
- ! int width = s.width();
- ! y.printon(s, base, width);
- ! }
- ! return s;
- ! #endif
- ! }
- !
- ! void Integer::printon(ostream& s, int base /* =10 */, int width /* =0 */) const
- ! {
- int align_right = !(s.flags() & ios::left);
- int showpos = s.flags() & ios::showpos;
- int showbase = s.flags() & ios::showbase;
- char fillchar = s.fill();
- char Xcase = (s.flags() & ios::uppercase)? 'X' : 'x';
- ! const IntRep* x = rep;
- int fmtlen = (x->len + 1) * I_SHIFT / lg(base) + 4 + width;
- char* fmtbase = new char[fmtlen];
- char* f = cvtItoa(x, fmtbase, fmtlen, base, showbase, width, align_right,
- ! fillchar, Xcase, showpos);
- s.write(f, fmtlen);
- delete fmtbase;
- }
-
- char* cvtItoa(const IntRep* x, char* fmt, int& fmtlen, int base, int showbase,
- int width, int align_right, char fillchar, char Xcase,
- ***************
- *** 2222,2228 ****
- ch += '0';
- *--s = ch;
- }
- ! delete z;
- break;
- }
- else
- --- 2227,2233 ----
- ch += '0';
- *--s = ch;
- }
- ! if (!STATIC_IntRep(z)) delete z;
- break;
- }
- else
- ***************
- *** 2390,2405 ****
-
- int Integer::OK() const
- {
- ! int v = rep != 0; // have a rep
- ! int l = rep->len;
- ! int s = rep->sgn;
- ! v &= l <= rep->sz; // length with bounds
- ! v &= s == 0 || s == 1; // legal sign
- ! Icheck(rep); // and correctly adjusted
- ! v &= rep->len == l;
- ! v &= rep->sgn == s;
- ! if (!v) error("invariant failure");
- ! return v;
- }
-
- void Integer::error(const char* msg) const
- --- 2395,2414 ----
-
- int Integer::OK() const
- {
- ! if (rep != 0)
- ! {
- ! int l = rep->len;
- ! int s = rep->sgn;
- ! int v = l <= rep->sz || STATIC_IntRep(rep); // length within bounds
- ! v &= s == 0 || s == 1; // legal sign
- ! Icheck(rep); // and correctly adjusted
- ! v &= rep->len == l;
- ! v &= rep->sgn == s;
- ! if (v)
- ! return v;
- ! }
- ! error("invariant failure");
- ! return 0;
- }
-
- void Integer::error(const char* msg) const
- *** 1.1 1992/03/22 07:42:32
- --- xobstack.cc 1992/06/03 14:00:13
- ***************
- *** 110,123 ****
- (*lib_error_handler)("Obstack", "invariant failure");
- return v;
- }
- -
- -
- - #ifdef VMS
- - #include "libgxx-io-ob.cc"
- - // The reason that this needs to be included is that if the modules for libg++
- - // are placed in a library, and libgxx-ob-io is in a seperate module, then
- - // that module contains only two symbols - the contstructor and destructor.
- - // they are not called explicitly anywhere else, so that module is not linked
- - // in, and the contstructor is not called. Chaos ensues.
- - #endif
- -
- --- 110,112 ----
- *** 1.1 1992/03/22 07:42:32
- --- xrationa.cc 1992/06/03 14:00:14
- ***************
- *** 23,30 ****
- #include <math.h>
- #include <values.h>
- #include <builtin.h>
-
- -
- void Rational::error(const char* msg) const
- {
- (*lib_error_handler)("Rational", msg);
- --- 23,30 ----
- #include <math.h>
- #include <values.h>
- #include <builtin.h>
- + #include <float.h>
-
- void Rational::error(const char* msg) const
- {
- (*lib_error_handler)("Rational", msg);
- ***************
- *** 393,400 ****
- int Rational::OK() const
- {
- int v = num.OK() && den.OK(); // have valid num and denom
- ! v &= sign(den) > 0; // denominator positive;
- ! v &= ucompare(gcd(num, den), _Int_One) == 0; // relatively prime
- if (!v) error("invariant failure");
- return v;
- }
- --- 393,415 ----
- int Rational::OK() const
- {
- int v = num.OK() && den.OK(); // have valid num and denom
- ! if (v)
- ! {
- ! v &= sign(den) > 0; // denominator positive;
- ! v &= ucompare(gcd(num, den), _Int_One) == 0; // relatively prime
- ! }
- if (!v) error("invariant failure");
- return v;
- + }
- +
- + int
- + Rational::fits_in_float() const
- + {
- + return FLT_MIN <= *this && *this <= FLT_MAX;
- + }
- +
- + int
- + Rational::fits_in_double() const
- + {
- + return DBL_MIN <= *this && *this <= DBL_MAX;
- }
- *** 1.1 1992/03/22 07:42:32
- --- xrng.cc 1992/06/03 14:00:14
- ***************
- *** 22,34 ****
- #include <builtin.h>
- #include <xrng.h>
-
- ! // these get initialized right in the ctors, but need default value in C++
- ! // (even if trash, as here)
- !
- ! PrivateRNGSingleType PrivateRNGSingleTypeInit;
- ! PrivateRNGDoubleType PrivateRNGDoubleTypeInit;
- ! PrivateRNGSingleType RNG::singleMantissa = PrivateRNGSingleTypeInit;
- ! PrivateRNGDoubleType RNG::doubleMantissa = PrivateRNGDoubleTypeInit;
-
- //
- // The scale constant is 2^-31. It is used to scale a 31 bit
- --- 22,30 ----
- #include <builtin.h>
- #include <xrng.h>
-
- ! // These two static fields get initialized by RNG::RNG().
- ! PrivateRNGSingleType RNG::singleMantissa;
- ! PrivateRNGDoubleType RNG::doubleMantissa;
-
- //
- // The scale constant is 2^-31. It is used to scale a 31 bit
- *** 1.1 1992/03/22 07:42:32
- --- xstring.cc 1992/06/03 14:00:15
- ***************
- *** 1206,1221 ****
- return s;
- }
- #else
- ! if (!s.ipfx(0))
- {
- s.set(ios::failbit); // Redundant if using GNU iostreams.
- return s;
- }
- #endif
- ! char ch;
- int i = 0;
- x.rep = Sresize(x.rep, 20);
- ! while (s.get(ch))
- {
- if (isspace(ch))
- break;
- --- 1206,1222 ----
- return s;
- }
- #else
- ! if (!s.ipfx(0) || (!(s.flags() & ios::skipws) && !ws(s)))
- {
- s.set(ios::failbit); // Redundant if using GNU iostreams.
- return s;
- }
- #endif
- ! int ch;
- int i = 0;
- x.rep = Sresize(x.rep, 20);
- ! register streambuf *sb = s.rdbuf();
- ! while ((ch = sb->sbumpc()) != EOF)
- {
- if (isspace(ch))
- break;
- ***************
- *** 1225,1231 ****
- }
- x.rep->s[i] = 0;
- x.rep->len = i;
- ! if(i == 0) s.clear(_bad);
- return s;
- }
-
- --- 1226,1233 ----
- }
- x.rep->s[i] = 0;
- x.rep->len = i;
- ! if (i == 0) s.set(_fail);
- ! if (ch == EOF) s.set(_eof);
- return s;
- }
-
- ***************
- *** 1239,1248 ****
- {
- return 0;
- }
- ! char ch;
- int i = 0;
- x.rep = Sresize(x.rep, 80);
- ! while (s.get(ch))
- {
- if (ch != terminator || !discard)
- {
- --- 1241,1251 ----
- {
- return 0;
- }
- ! int ch;
- int i = 0;
- x.rep = Sresize(x.rep, 80);
- ! register streambuf *sb = s.rdbuf();
- ! while ((ch = sb->sbumpc()) != EOF)
- {
- if (ch != terminator || !discard)
- {
- ***************
- *** 1255,1260 ****
- --- 1258,1264 ----
- }
- x.rep->s[i] = 0;
- x.rep->len = i;
- + if (ch == EOF) s.set(_eof);
- return i;
- }
-
- ***************
- *** 1305,1315 ****
-
- int String::OK() const
- {
- ! int v = rep != 0; // have a rep
- ! v &= rep->len <= rep->sz; // string within bounds
- ! v &= rep->s[rep->len] == 0; // null-terminated
- ! if (!v) error("invariant failure");
- ! return v;
- }
-
- int SubString::OK() const
- --- 1309,1319 ----
-
- int String::OK() const
- {
- ! if (rep == 0 // don't have a rep
- ! || rep->len > rep->sz // string oustide bounds
- ! || rep->s[rep->len] != 0) // not null-terminated
- ! error("invariant failure");
- ! return 1;
- }
-
- int SubString::OK() const
-